#include <bits/stdc++.h>
#ifndef DEBUG
#define debug
#endif
using namespace std;
using i64 = int64_t;

int main() {
  cin.tie(0)->sync_with_stdio(0);
  string str;
  cin >> str;
  int n = str.size();
  vector<vector<int>> comp(n, vector<int>(n, INT_MAX));
  for (int l = 0; l < n; l ++) {
    for (int r = l; r < n; r ++) {
      comp[l][r] = INT_MAX;
      for (int k = l + 1; k <= r; k += 2) {
        // [l, k] repeat (k, r]
        int len = k - l + 1;
        int half = len / 2;
        // 这一步可以用 KMP 优化
        if ([&]() {
          for (int i = 0; i < half; i ++) {
            if (str[l + i] != str[l + half + i]) return true;
          }
          return false;
        }()) continue;
        comp[l][r] = min(comp[l][r], min(half, comp[l][l + half - 1]) + 1 + r - k);
      }
    }
  }
  vector<int> dp(n);
  for (int i = 0; i < n; i ++) {
    dp[i] = min(i + 1, comp[0][i]);
    for (int j = 1; j <= i; j ++) {
      if (comp[j][i] != INT_MAX) {
        dp[i] = min(dp[i], dp[j - 1] + comp[j][i] + 1);
      }
    }
  }
  cout << dp[n - 1] << endl;
}

//  MaRbRcR
//  MaabRcR
//  MaabaabcR
//   aabaabcaabaabc
// bcbc
// bcR